/*     */ package com.qmsk.business.task.notes.controller;
/*     */ 
/*     */ import com.qmsk.business.bussBill.bussBill.dao.BussBillDao;
/*     */ import com.qmsk.business.manage.community.dao.CommunityDAO;
/*     */ import com.qmsk.business.member.memberIntegralBill.dao.MemberIntegralBillDao;
/*     */ import com.qmsk.business.member.memberIntegralDetail.dao.MemberIntegralDetailDAO;
/*     */ import com.qmsk.business.member.memberIntegralRule.dao.MemberIntegralRuleDAO;
/*     */ import com.qmsk.business.member.shopMember.dao.ShopMemberDAO;
/*     */ import com.qmsk.business.task.notes.dao.NoteImageDao;
/*     */ import com.qmsk.business.task.notes.dao.NotePraiseDao;
/*     */ import com.qmsk.business.task.notes.dao.NotesDao;
/*     */ import com.qmsk.business.weixin.customMenu.weiXinUtil.WeiXinUtil;
/*     */ import com.utils.basic.CFileComm;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.file.GlobalParams;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.gson.out.GsonEbRstData;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.File;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.fileupload.FileItem;
/*     */ import org.apache.commons.fileupload.FileUploadException;
/*     */ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
/*     */ import org.apache.commons.fileupload.servlet.ServletFileUpload;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"notes"})
/*     */ public class NotesController
/*     */ {
/*  52 */   private static final Logger logger = Logger.getLogger(NotesController.class);
/*     */ 
/*     */   @Autowired
/*     */   private NotesDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private NoteImageDao noteImageDao;
/*     */ 
/*     */   @Autowired
/*     */   private NotePraiseDao notePraiseDao;
/*     */ 
/*     */   @Autowired
/*     */   private CommunityDAO communDao;
/*     */ 
/*     */   @Autowired
/*     */   private ShopMemberDAO shopMemberDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralRuleDAO memberIntegralRuleDAO;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillDao bussBillDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralBillDao memberIntegralBillDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralDetailDAO memberIntegralDetailDAO;
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response) { try { int nResult = 0;
/*  84 */       String sData = RequestUtils.getStringOfData(request);
/*  85 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*  86 */       if ((p != null) && (p.isExistsInsertRows())) {
/*  87 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*     */ 
/*  89 */         g.autoAddHeadData("createdTime", new Date());
/*  90 */         g.autoAddHeadData("nums", Integer.valueOf(0));
/*  91 */         g.autoAddHeadData("praiseNums", Integer.valueOf(0));
/*  92 */         g.autoAddHeadData("discussNums", Integer.valueOf(0));
/*  93 */         g.autoAddHeadData("status", Integer.valueOf(0));
/*  94 */         Long communityId = ObjectComm.objectToLong(g.getValueOfName("communityId"));
/*  95 */         nResult = this.dao.applyUpdates(p, "id");
/*  96 */         if (nResult > 0) {
/*  97 */           nResult = this.communDao.updateNoteNum(communityId);
/*  98 */           if (nResult > 0)
/*     */           {
/* 100 */             GsonHeadOneRow gs = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 101 */             Long id = ObjectComm.objectToLong(gs.getValueOfName("id"));
/* 102 */             String[] head = { "id" };
/* 103 */             Object[] data = { id };
/* 104 */             DbConnection.commit();
/* 105 */             ResponseUtils.toGsonEbRst(head, data, response);
/* 106 */             return;
/*     */           }
/*     */         } else {
/* 109 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 112 */       DbConnection.rollback();
/*     */ 
/* 114 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 115 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 116 */         response);
/*     */     } catch (Exception e) {
/* 118 */       logger.error(e);
/* 119 */       DbConnection.rollback();
/* 120 */       ResponseUtils.setErrorMsgResponse(
/* 121 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 122 */         e.getMessage(), response); }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/insertInfo2"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert2(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 129 */       int nResult = 0;
/* 130 */       String sData = RequestUtils.getStringOfData(request);
/* 131 */       String image = RequestUtils.getString(request, "image");
/* 132 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 133 */       ParserDataSetJson p2 = ParserDataSetJson.fromString(image);
/* 134 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 135 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 136 */         Long memberId = ObjectComm.objectToLong(g.getValueOfName("customerId"));
/* 137 */         Long shopId = ObjectComm.objectToLong(g.getValueOfName("shopId"));
/*     */         Long RuleID;
/* 139 */         if (this.dao.checkExistbyMemberId(memberId, shopId).intValue() <= 0) {
/* 140 */           String openId = ObjectComm.objectToString(g.getValueOfName("openId"));
/* 141 */           String customerName = ObjectComm.objectToString(g.getValueOfName("customerName"));
/* 142 */           GsonEbRst intg = this.memberIntegralRuleDAO.getGsonOfName("签到");
/* 143 */           Integer intAmt = Integer.valueOf(0);
/* 144 */           String intAmtContent = "";
/* 145 */           if ((intg != null) && (intg.getDataLength() > 0)) {
/* 146 */             RuleID = (Long)intg.getResult().getValueOfIdx(0, "RuleID");
/* 147 */             intAmt = (Integer)intg.getResult().getValueOfIdx(0, "FixedIntegral");
/* 148 */             intAmtContent = ",您已获得" + intAmt + "个积分";
/* 149 */             Map params = new HashMap();
/* 150 */             params.put("memberId", memberId);
/* 151 */             params.put("shopId", shopId);
/* 152 */             params.put("intAmt", intAmt);
/* 153 */             nResult = this.shopMemberDAO.updateBissBillAmountInc(params);
/* 154 */             String billNO = this.bussBillDao.getMaxBillNo(shopId);
/* 155 */             String[] head = { "ShopID", "BillNo", "MemberID", "CustName", "GotIntAmt" };
/* 156 */             Object[] data = { shopId, billNO, memberId, customerName, intAmt };
/* 157 */             nResult = this.bussBillDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/* 158 */             if (nResult > 0) {
/* 159 */               Long billId = this.bussBillDao.getLastId();
/* 160 */               nResult = this.memberIntegralBillDao.insertBsBillInAmtOfService(billNO, memberId, shopId, intAmt, RuleID, "签到", null, null, billId, null);
/* 161 */               if (nResult > 0) {
/* 162 */                 String[] detilHead = { "ShopID", "Integral", "MemberID", "BillID", "Status" };
/* 163 */                 Object[] detilData = { shopId, intAmt, memberId, billId, Integer.valueOf(0) };
/* 164 */                 nResult = this.memberIntegralDetailDAO.insertGsonHeadOneRow(new GsonHeadOneRow(detilHead, detilData));
/*     */               }
/*     */             }
/* 167 */             WeiXinUtil.sendTextMessageOfMain("尊敬的" + customerName + ":\n感谢您签到微社区" + intAmtContent, openId);
/*     */           }
/*     */         }
/*     */ 
/* 171 */         g.autoAddHeadData("createdTime", new Date());
/* 172 */         g.autoAddHeadData("nums", Integer.valueOf(0));
/* 173 */         g.autoAddHeadData("praiseNums", Integer.valueOf(0));
/* 174 */         g.autoAddHeadData("discussNums", Integer.valueOf(0));
/* 175 */         g.autoAddHeadData("status", Integer.valueOf(0));
/* 176 */         Long communityId = ObjectComm.objectToLong(g.getValueOfName("communityId"));
/* 177 */         nResult = this.dao.applyUpdates(p, "id");
/* 178 */         if (nResult > 0)
/*     */         {
/* 180 */           nResult = this.communDao.updateNoteNum(communityId);
/* 181 */           if (nResult > 0) {
/* 182 */             GsonHeadOneRow gs = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 183 */             Long id = ObjectComm.objectToLong(gs.getValueOfName("id"));
/* 184 */             if ((p2 != null) && (p2.isExistsInsertRows())) {
/* 185 */               for (GsonHeadOneRow gi : p2.getListInsertRows()) {
/* 186 */                 gi.autoAddHeadData("noteId", id);
/*     */               }
/* 188 */               nResult = this.noteImageDao.applyUpdates(p2);
/*     */             }
/* 190 */             String[] head = { "id" };
/* 191 */             Object[] data = { id };
/* 192 */             DbConnection.commit();
/* 193 */             ResponseUtils.toGsonEbRst(head, data, response);
/* 194 */             return;
/*     */           }
/*     */         } else {
/* 197 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 200 */       DbConnection.rollback();
/*     */ 
/* 202 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 203 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 204 */         response);
/*     */     } catch (Exception e) {
/* 206 */       logger.error(e);
/* 207 */       DbConnection.rollback();
/* 208 */       ResponseUtils.setErrorMsgResponse(
/* 209 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 210 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"insert/insertParise"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertParise(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 217 */       int nResult = 0;
/* 218 */       String sData = RequestUtils.getStringOfData(request);
/* 219 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 220 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 221 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 222 */         Long id = ObjectComm.objectToLong(g.getValueOfName("noteId"));
/* 223 */         Long memberId = ObjectComm.objectToLong(g.getValueOfName("memberId"));
/* 224 */         nResult = this.notePraiseDao.checkMemberId(id, memberId);
/* 225 */         if (nResult == 1) {
/* 226 */           ResponseUtils.setErrorMsgResponse("您已经点过赞", response);
/* 227 */           return;
/*     */         }
/* 229 */         nResult = this.notePraiseDao.applyUpdates(p);
/* 230 */         nResult = this.dao.updatePraiseNums(id);
/* 231 */         if (nResult > 0)
/* 232 */           DbConnection.commit();
/*     */         else {
/* 234 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 237 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 238 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 239 */         response);
/*     */     } catch (Exception e) {
/* 241 */       logger.error(e);
/* 242 */       DbConnection.rollback();
/* 243 */       ResponseUtils.setErrorMsgResponse(
/* 244 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 245 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/imageList"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void imageList(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try {
/* 253 */       Long id = RequestUtils.getLong(request, "id");
/* 254 */       GsonEbRst gsonEbRst = this.noteImageDao.getGsonOfAll(id);
/* 255 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 257 */       logger.error(e);
/* 258 */       ResponseUtils.setErrorMsgResponse(
/* 259 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/noteList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 266 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 268 */       Map params = new HashMap();
/* 269 */       MapUtils.addToMap(params, "status", Integer.valueOf(0));
/* 270 */       String shopId = RequestUtils.getString(request, "shopId");
/* 271 */       String id = RequestUtils.getString(request, "id");
/* 272 */       String memberId = RequestUtils.getString(request, "memberId");
/* 273 */       String thisMemberId = RequestUtils.getString(request, "ownId");
/* 274 */       if (StringUtils.isEmpty(memberId)) {
/* 275 */         memberId = "0";
/*     */       }
/* 277 */       MapUtils.addToMap(params, "shopId", shopId);
/* 278 */       MapUtils.addToMap(params, "id", id);
/* 279 */       MapUtils.addToMap(params, "memberId", memberId);
/* 280 */       MapUtils.addToMap(params, "customerId", thisMemberId);
/* 281 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 282 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 284 */       logger.error(e);
/* 285 */       ResponseUtils.setErrorMsgResponse(
/* 286 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/note"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try {
/* 294 */       Map params = new HashMap();
/* 295 */       MapUtils.addToMap(params, "status", Integer.valueOf(0));
/* 296 */       String shopId = RequestUtils.getString(request, "shopId");
/* 297 */       String id = RequestUtils.getString(request, "id");
/* 298 */       String memberId = RequestUtils.getString(request, "memberId");
/* 299 */       if (StringUtils.isEmpty(memberId)) {
/* 300 */         memberId = "0";
/*     */       }
/* 302 */       MapUtils.addToMap(params, "shopId", shopId);
/* 303 */       MapUtils.addToMap(params, "id", id);
/* 304 */       MapUtils.addToMap(params, "memberId", memberId);
/* 305 */       int nResult = this.dao.updateNum(id);
/* 306 */       if (nResult > 0)
/* 307 */         this.dao.commit();
/*     */       else {
/* 309 */         this.dao.rollback();
/*     */       }
/* 311 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params);
/* 312 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 314 */       logger.error(e);
/* 315 */       ResponseUtils.setErrorMsgResponse(
/* 316 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/findLastMeglie"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void findLastMeglie(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 323 */       Map params = new HashMap();
/* 324 */       MapUtils.addToMap(params, "customerId", RequestUtils.getString(request, "memberId"));
/* 325 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params);
/* 326 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 328 */       logger.error(e);
/* 329 */       ResponseUtils.setErrorMsgResponse(
/* 330 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 340 */       int nResult = 0;
/* 341 */       String sData = RequestUtils.getStringOfData(request);
/* 342 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 343 */       if (p != null) {
/* 344 */         nResult = this.dao.applyUpdates(p);
/* 345 */         if (nResult > 0)
/* 346 */           DbConnection.commit();
/*     */         else {
/* 348 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 351 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 352 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 353 */         response);
/*     */     } catch (Exception e) {
/* 355 */       logger.error(e);
/* 356 */       DbConnection.rollback();
/* 357 */       ResponseUtils.setErrorMsgResponse(
/* 358 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 359 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 367 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 369 */       String[] strParams = id.split(",");
/* 370 */       int nResult = this.dao.deleteParams(strParams);
/* 371 */       if (nResult > 0)
/* 372 */         DbConnection.commit();
/*     */       else {
/* 374 */         DbConnection.rollback();
/*     */       }
/* 376 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 377 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 378 */         response);
/*     */     } catch (Exception e) {
/* 380 */       DbConnection.rollback();
/* 381 */       logger.error(e);
/* 382 */       ResponseUtils.setErrorMsgResponse(
/* 383 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 384 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"upload/image/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void uploadImages(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id) {
/*     */     try {
/* 391 */       String path = GlobalParams.getGlobalParams().getApacheRoot() + 
/* 392 */         "notes/" + "allImage/";
/* 393 */       String httpPath = GlobalParams.getGlobalParams().getApacheUrl() + 
/* 394 */         "notes/" + "allImage/";
/*     */ 
/* 396 */       List<String> listFileName = new ArrayList();
/*     */ 
/* 398 */       String ids = request.getParameter("ids");
/* 399 */       String[] names = ids.split(",");
/* 400 */       List namesList = new ArrayList();
/* 401 */       for (int i = 0; i < names.length; ++i) {
/* 402 */         namesList.add(Long.valueOf(new Date().getTime()));
/*     */       }
/* 404 */       uploadFileOfRequest(request, response, path, listFileName, 
/* 405 */         namesList);
/* 406 */       String paths = "";
/* 407 */       if (listFileName != null) {
/* 408 */         for (String str : listFileName) {
/* 409 */           if (StringUtils.isNotEmpty(str)) {
/* 410 */             paths = httpPath + str;
/*     */           }
/*     */         }
/*     */       }
/* 414 */       if (StringUtils.isNotEmpty(paths))
/*     */       {
/* 416 */         String[] head = { "imageUrl" };
/* 417 */         Object[] data = { paths };
/* 418 */         ResponseUtils.toGsonEbRst(head, data, response);
/* 419 */         return;
/*     */       }
/*     */ 
/* 422 */       ResponseUtils.setErrorMsgResponse(
/* 423 */         RequestUtils.getUploadPicErrorMessage(request), 
/* 424 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 427 */       logger.error(e);
/* 428 */       ResponseUtils.setErrorMsgResponse(
/* 429 */         RequestUtils.getUploadPicErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"upload/images/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void uploadImage(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id) {
/*     */     try {
/* 436 */       String path = GlobalParams.getGlobalParams().getApacheRoot() + 
/* 437 */         "notes/" + "img/" + id + "/";
/* 438 */       String httpPath = GlobalParams.getGlobalParams().getApacheUrl() + 
/* 439 */         "notes/" + "img/" + id + "/";
/*     */ 
/* 441 */       List<String> listFileName = new ArrayList();
/*     */ 
/* 443 */       String ids = request.getParameter("ids");
/* 444 */       String[] names = ids.split(",");
/* 445 */       List namesList = new ArrayList();
/* 446 */       for (int i = 0; i < names.length; ++i) {
/* 447 */         namesList.add(names[i]);
/*     */       }
/* 449 */       uploadFileOfRequest(request, response, path, listFileName, 
/* 450 */         namesList);
/* 451 */       String paths = "";
/* 452 */       int sResult = 0;
/* 453 */       if (listFileName != null) {
/* 454 */         for (String str : listFileName) {
/* 455 */           if (StringUtils.isNotEmpty(str)) {
/* 456 */             paths = httpPath + str;
/* 457 */             String[] heads = { "imageUrl", "noteId" };
/* 458 */             Object[] objects = { paths, id };
/* 459 */             sResult = this.noteImageDao.insertGsonHeadOneRow(new GsonHeadOneRow(heads, objects));
/*     */           }
/*     */         }
/*     */       }
/* 463 */       if (StringUtils.isNotEmpty(paths))
/*     */       {
/* 465 */         if (sResult > 0) {
/* 466 */           this.noteImageDao.commit();
/* 467 */           ResponseUtils.setSuccessResponse(paths, response);
/* 468 */           return; }
/* 469 */         this.noteImageDao.rollback();
/* 470 */         ResponseUtils.setErrorMsgResponse(
/* 471 */           RequestUtils.getUploadPicErrorMessage(request), 
/* 472 */           response);
/*     */ 
/* 474 */         return; }
/* 475 */       this.noteImageDao.rollback();
/* 476 */       ResponseUtils.setErrorMsgResponse(
/* 477 */         RequestUtils.getUploadPicErrorMessage(request), 
/* 478 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 481 */       logger.error(e);
/* 482 */       ResponseUtils.setErrorMsgResponse(
/* 483 */         RequestUtils.getUploadPicErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   private static void uploadFileOfRequest(HttpServletRequest request, HttpServletResponse response, String sDir, List<String> listFileName, List<String> appointNames)
/*     */     throws ServletException, IOException
/*     */   {
/* 490 */     request.setCharacterEncoding("UTF-8");
/* 491 */     response.setContentType("text/html;charset=UTF-8");
/*     */ 
/* 493 */     DiskFileItemFactory factory = new DiskFileItemFactory();
/* 494 */     factory.setSizeThreshold(1024);
/* 495 */     ServletFileUpload upload = new ServletFileUpload(factory);
/*     */ 
/* 497 */     upload.setSizeMax(104857600L);
/*     */     try
/*     */     {
/* 500 */       List fileItems = upload.parseRequest(request);
/*     */ 
/* 502 */       Iterator iter = fileItems.iterator();
/* 503 */       Iterator nameIt = appointNames.iterator();
/* 504 */       String appointName = null;
/* 505 */       while (iter.hasNext()) {
/* 506 */         FileItem item = (FileItem)iter.next();
/* 507 */         appointName = nameIt.next().toString();
/*     */ 
/* 509 */         if (item.isFormField())
/*     */           continue;
/* 511 */         String name = item.getName();
/* 512 */         logger.info("item: " + name);
/* 513 */         logger.info("appointName: " + appointName);
/* 514 */         String extName = name.substring(name.lastIndexOf("."));
/* 515 */         String saveFileName = appointName + extName;
/* 516 */         System.out.println("saveFilename:" + saveFileName);
/* 517 */         if (listFileName != null) {
/* 518 */           listFileName.add(saveFileName);
/*     */         }
/*     */         try
/*     */         {
/* 522 */           logger.info("upload dir:" + sDir);
/* 523 */           File filePath = new File(sDir);
/* 524 */           if (!(filePath.exists())) {
/* 525 */             logger.info("dir isn't exists:" + sDir);
/* 526 */             filePath.mkdirs();
/*     */ 
/* 528 */             CFileComm.setExecutablePermission(filePath);
/*     */           } else {
/* 530 */             logger.info("dir is exists:" + sDir);
/*     */           }
/* 532 */           File fileItem = new File(sDir + saveFileName);
/* 533 */           logger.info("sDir_item: " + sDir + saveFileName);
/* 534 */           item.write(fileItem);
/*     */ 
/* 536 */           CFileComm.setExecutablePermission(fileItem);
/*     */         } catch (Exception e) {
/* 538 */           logger.error(e.getMessage());
/*     */         }
/*     */       }
/*     */     }
/*     */     catch (FileUploadException e) {
/* 543 */       logger.error(e.getMessage());
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.notes.controller.NotesController
 * JD-Core Version:    0.5.3
 */